/**
 * Copyright (c) 2013-Now http://jeesite.com All rights reserved.
 * No deletion without permission, or be held responsible to law.
 * @author YDZ
 */
import { defHttp } from '/@/utils/http/axios';
import { useGlobSetting } from '/@/hooks/setting';
import { BasicModel, Page } from '../model/baseModel';
import { UploadApiResult } from '../sys/upload';
import { UploadFileParams } from '/#/axios';

const { ctxPath, adminPath } = useGlobSetting();

export interface BasUserCus extends BasicModel<BasUserCus> {
  userCode?: string; // 客户名称
  cusCode?: string; // 客户编码
}

export const basUserCusList = (params?: BasUserCus | any) =>
  defHttp.get<BasUserCus>({ url: adminPath + '/bas/cus/basUserCus/list', params });

export const basUserCusListData = (params?: BasUserCus | any) =>
  defHttp.post<Page<BasUserCus>>({ url: adminPath + '/bas/cus/basUserCus/listData', params });

export const basUserCusForm = (params?: BasUserCus | any) =>
  defHttp.get<BasUserCus>({ url: adminPath + '/bas/cus/basUserCus/form', params });

export const basUserCusSave = (params?: any, data?: BasUserCus | any) =>
  defHttp.postJson<BasUserCus>({ url: adminPath + '/bas/cus/basUserCus/save', params, data });

export const basUserCusDelete = (params?: BasUserCus | any) =>
  defHttp.get<BasUserCus>({ url: adminPath + '/bas/cus/basUserCus/delete', params });

export const saveCusAndUser = (params?: any, data?: BasUserCus | any) =>
  defHttp.postJson<BasUserCus>({
    url: adminPath + '/bas/cus/basUserCus/saveCusAndUser',
    params,
    data,
  });

export const deleteAuthCus = (params?: any, data?: BasUserCus | any) =>
  defHttp.postJson<BasUserCus>({
    url: adminPath + '/bas/cus/basUserCus/deleteAuthCus',
    params,
    data,
  });

export const setDefaultCus = (params?: any, data?: BasUserCus | any) =>
  defHttp.postJson<BasUserCus>({
    url: adminPath + '/bas/cus/basUserCus/setDefaultCus',
    params,
    data,
  });

export const basUserCusImportData = (
  params: UploadFileParams,
  onUploadProgress: (progressEvent: ProgressEvent) => void,
) =>
  defHttp.uploadFile<UploadApiResult>(
    {
      url: ctxPath + adminPath + '/bas/cus/basUserCus/importData',
      onUploadProgress,
    },
    params,
  );

export const basUserCusTreeData = (params?: BasUserCus | any) =>
  defHttp.post<BasUserCus>({ url: adminPath + '/bas/cus/basUserCus/treeData', params });
